<?php
/*
 * by: PhpStorm
 * 2021/7/23
 * 22:02
 * User: jweicao@qq.com
 */

namespace App\Api\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;


class PromotionOrderlist extends Model
{
    use HasFactory;
    protected $guarded = [];
    protected $table = 'cmc_promotions_orderlist';

    /**
     * 查询有效时间内数据 并获取指定字段
     * @param $field
     * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
     */
    public static function saveData($data, $where = [])
    {
        if (!empty($where) && is_array($where)) {
            return self::query()->where($where)->update($data);
        }
        return self::query()->create($data);
    }

     /**
     * 查询用户消费记录
     * @param $memberId 用户id
     * @param $allowField 查询字段
     * @return mixed
     */
    public static function getRecordsData($memberId,$allowField)
    {
        return self::where('uid',$memberId)->select($allowField)->get()->toArray();
    }


}
